<?php

namespace App\Repositories\Basic;

use App\Models\Basic\Product;
use App\Repositories\BaseRepository;

class ProductRepository extends BaseRepository
{
    public function __construct(Product $model)
    {
        parent::__construct($model);
    }

    public function getListWithStock($columns = ['*'],$where=[],$page=1,$limit=15,$sort='created_at',$order='desc')
    {
        //todo 商品表-商品库存表-列表
        return $this->model->with(['productStocks'=>function ($query){
            $query->with('storage');
        }])->where($where)
            ->orderBy($sort, $order)
            ->paginate($limit, $columns, 'page', $page);
    }
}